<?php
//部门
namespace app\crm\model;

use think\Db;

class Custype extends \ShopModel
{
    protected $table = 'sh_client_category';
    protected $pk = 'client_cate_id';
    public function getalltype(){
        return $this->field("client_cate_id,client_cate_name,times,seetype,department_list,staff_list")->select();
    }
    public function ishas($type_name,$type_id){
        if($type_id){
            $where="client_cate_name='{$type_name}' and client_cate_id<>{$type_id}";
        }else{
            $where="client_cate_name='{$type_name}'";
        }
        return $this->where($where)->find();
    }
    public function addnew($data){
        return $this->insertGetId($data);
    }
    public function updatenew($data,$type_id){
        return $this->where(["client_cate_id"=>$type_id])->update($data);
    }
    public function deletebyid($type_id){
        return $this->where(["client_cate_id"=>$type_id])->delete();
    }
}
